
<template>
  <div class="module_pannel_container">
    <div class="module_pannel_nav">
      <a-radio-group default-value="b" button-style="solid">
        <a-radio-button value="a" style="width: 80px; text-align: center">
          <a-icon type="shop" />
        </a-radio-button>
        <a-radio-button value="b" style="width: 80px; text-align: center">
          <a-icon type="switcher" />
        </a-radio-button>
      </a-radio-group>
    </div>
    <div class="module_pannel">
      <a-collapse
        style="width: 100%"
        v-model="activeKey"
        expand-icon-position="right"
      >
        <a-collapse-panel key="1" header="基础组件">
          <div class="moduel_item_container">
            <div
              class="module_item"
              v-for="(item, index) in components.base"
              :key="index"
              @dragstart="dragstart(item, $event)"
            >
              <img class="module_img" :src="item.img" alt="" />
              <span>{{ item.name }}</span>
            </div>
          </div>
        </a-collapse-panel>
        <a-collapse-panel key="2" header="高级组件">
          <div class="moduel_item_container">
            <div
              class="module_item"
              v-for="(item, index) in components.base"
              :key="index"
              @dragstart="dragstart(item, $event)"
            >
              <img
                class="module_img"
                src="https://cdn2.weimob.com/saas/@assets/saas-fe-retail-web-stc/retail2/images/storeDesign/module_icon/video.png"
                alt=""
              />
              <span>图片</span>
            </div>
          </div>
        </a-collapse-panel>
      </a-collapse>
    </div>
  </div>
</template>
<script>
import { components } from "@/util/const";
import { mapMutations } from "vuex";
export default {
  data() {
    return {
      components: components,
      activeKey: ["1"],
    };
  },
  methods: {
    dragstart(item, ev) {
      item.extra = {
        width: ev.currentTarget.offsetWidth,
        height: ev.currentTarget.offsetHeight,
        pointX: ev.offsetX,
        pointY: ev.offsetY,
      };
      ev.dataTransfer.setData("component", JSON.stringify(item));
      this.setDragComponent(item);
    },
    click() {},
    ...mapMutations(["setDragComponent"]),
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.module_pannel_container {
  position: relative;
  width: 300px;
  min-width: 300px;
  background: #fff;
  box-sizing: border-box;
  padding: 5px 0;
  .module_pannel_nav {
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .module_pannel {
    background: #fff;
    width: 100%;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 10px;
    position: absolute;
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    &::-webkit-scrollbar {
      display: none; /* Chrome Safari */
    }
    .moduel_item_container {
      display: flex;
      // justify-content: space-around;
      flex-wrap: wrap;
      margin-bottom: 20px;
      .module_item {
        width: 75px;
        font-size: 12px;
        text-align: center;
        color: #595961;
        // background: blue;
        display: inline-block;
        transition: 0.1s;
        cursor: move;
        &:hover {
          background: #f8f8f8;
        }
        .module_img {
          width: 70px;
          height: auto;
          margin: 0 auto 1px;
          display: block;
        }
      }
    }
  }
  .ant-collapse {
    border: none !important;
    background-color: #fff;
  }

  .ant-collapse-item {
    border: none !important;
    // margin-bottom: 10px;
  }
  .ant-collapse-content {
    border-top: none !important;
    background: red;
  }
  .ant-collapse-content-box {
    padding: 0 !important;
    background: red !important;
  }
}
</style>